<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>CreateRef</title>
</head>
    <body>
        <!-- 引入React核心库 -->
        <script src="../JS/react.development.js"></script>
        <!-- 引入ReactDOM，用于支持react操作DOM -->
        <script src="../JS/react-dom.development.js"></script>
        <!-- 引入babel 用于将书写的JSX语法 编译成JS语法 -->
        <script src="../JS/babel.min.js"></script>
        <div id="test"></div>
        <script type="text/babel">
            
            class Demo extends React.Component{
                /* 
                    React.createRef() 调用后 可以返回一个容器, 该容器可以存储呗ref标识的节点,该容器是 "专人专用"的
                */
                myRef = React.createRef()
                showData= ()=>{
                    console.log(this.myRef.current.value);
                }

                render(){
                    return(
                        <div>   
                            <input ref={this.myRef} type="text" />
                            <button onClick={this.showData}>点击输出数据</button>
                        </div>
                    )
                }

            }
            ReactDOM.render(<Demo/>, document.getElementById('test'))

        </script>




        
    </body>
</html>